package a.e.b.c;

import a.c.q;
import org.w3c.dom.*;
import org.xml.sax.helpers.NamespaceSupport;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.OutputStream;
import java.io.Writer;
import java.util.LinkedList;

public class i
  extends h
{
  private Document c;
  private LinkedList d;
  private String e = "UTF-8";
  private Result f;
  private DocumentBuilder g;
  private boolean i = true;
  public static boolean j;
  
  public boolean h()
  {
    return this.i;
  }
  
  public i(OutputStream paramOutputStream, String paramString)
    throws a
  {
    this(a(paramOutputStream));
    this.e = paramString;
  }
  
  public i(Writer paramWriter)
    throws a
  {
    this(a(paramWriter));
  }
  
  public i(Result paramResult)
    throws a
  {
    this.f = paramResult;
    DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
    localDocumentBuilderFactory.setNamespaceAware(true);
    try
    {
      this.g = localDocumentBuilderFactory.newDocumentBuilder();
    }
    catch (ParserConfigurationException localParserConfigurationException)
    {
      throw new a("Error configuring internal DOM tree:", localParserConfigurationException);
    }
  }
  
  public void a(boolean paramBoolean)
  {
    this.i = paramBoolean;
  }
  
  public cb a(String paramString)
  {
    boolean bool = a.b;
    Comment localComment = this.c.createComment(paramString);
    if (!bool)
    {
      if (this.d.size() == 0)
      {
        if (bool) {
          break label85;
        }
        this.c.appendChild(localComment);
        if (!a.a) {}
      }
      else
      {
        if (bool) {
          break label85;
        }
      }
    }
    else
    {
      Object localObject = this.d.getLast();
      if ((localObject instanceof Node)) {
        ((Node)localObject).appendChild(localComment);
      }
    }
    label85:
    return this;
  }
  
  public cb b(String paramString1, String paramString2)
  {
    ProcessingInstruction localProcessingInstruction = this.c.createProcessingInstruction(paramString1, paramString2);
    Object localObject = this.d.getLast();
    if ((a.b) || ((localObject instanceof Node))) {
      ((Node)localObject).appendChild(localProcessingInstruction);
    }
    return this;
  }
  
  public cb c()
  {
    this.c = this.g.newDocument();
    this.d = new LinkedList();
    return this;
  }
  
  public void a()
  {
    this.d = null;
  }
  
  public void d()
    throws a
  {
    Transformer localTransformer = i();
    try
    {
      a(localTransformer);
      DOMSource localDOMSource = new DOMSource(this.c);
      localTransformer.transform(localDOMSource, this.f);
    }
    catch (TransformerException localTransformerException)
    {
      throw new a("Error transforming internal DOM tree:", localTransformerException);
    }
  }
  
  protected void a(Transformer paramTransformer)
  {
    if (!this.i) {
      paramTransformer.setOutputProperty("omit-xml-declaration", "yes");
    }
    paramTransformer.setOutputProperty("method", "xml");
    paramTransformer.setOutputProperty("indent", "yes");
    paramTransformer.setOutputProperty("encoding", this.e);
    try
    {
      paramTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
  }
  
  protected Transformer i()
    throws a
  {
    TransformerFactory localTransformerFactory = TransformerFactory.newInstance();
    try
    {
      localTransformerFactory.setAttribute("indent-number", "2");
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
    Transformer localTransformer;
    try
    {
      localTransformer = localTransformerFactory.newTransformer();
    }
    catch (TransformerConfigurationException localTransformerConfigurationException)
    {
      throw new a("Error transforming internal DOM tree:", localTransformerConfigurationException);
    }
    return localTransformer;
  }
  
  private static Result a(OutputStream paramOutputStream)
  {
    return new StreamResult(paramOutputStream);
  }
  
  private static Result a(Writer paramWriter)
  {
    return new StreamResult(paramWriter);
  }
  
  protected void b(String paramString1, String paramString2, String paramString3)
  {
    boolean bool2 = a.b;
    boolean bool1 = a.a;
    if ((bool2) || (this.d == null)) {
      c();
    }
    Element localElement;
    if (paramString3 == null)
    {
      localElement = this.c.createElement(paramString2);
      if (bool2) {
        break label107;
      }
      if (!bool1) {}
    }
    else
    {
      localElement = this.c.createElementNS(paramString3, paramString2);
      if ((bool2) || (paramString1 != null))
      {
        if (bool2) {
          break label107;
        }
        if (paramString1.length() > 0) {
          localElement.setPrefix(paramString1);
        }
      }
    }
    if (!bool2) {
      if (this.d.size() == 0)
      {
        label107:
        this.c.appendChild(localElement);
        if (bool2) {
          break label148;
        }
        this.d.addLast(localElement);
        if (!bool1) {
          return;
        }
      }
    }
    label148:
    Object localObject = this.d.getLast();
    if ((bool2) || ((localObject instanceof Node)))
    {
      ((Node)localObject).appendChild(localElement);
      this.d.addLast(localElement);
    }
  }
  
  protected void f()
  {
    this.d.removeLast();
  }
  
  protected void b(String paramString1, String paramString2, String paramString3, String paramString4)
  {
    boolean bool2 = a.b;
    boolean bool1 = a.a;
    Object localObject = this.d.getLast();
    if ((localObject instanceof Element))
    {
      if (!bool2) {
        if (paramString3 != null)
        {
          if (bool2) {
            break label67;
          }
          if (paramString3.length() != 0) {
            break label66;
          }
        }
      }
      ((Element)localObject).setAttribute(paramString2, paramString4);
      if (bool1)
      {
        label66:
        label67:
        if (!bool2) {
          if (paramString1 != null)
          {
            if (bool2) {
              break label113;
            }
            if (paramString1.length() != 0) {
              break label111;
            }
          }
        }
        if (!bool2)
        {
          ((Element)localObject).setAttributeNS(paramString3, paramString2, paramString4);
          if (!bool1) {}
        }
        else
        {
          label111:
          label113:
          ((Element)localObject).setAttributeNS(paramString3, paramString1 + ":" + paramString2, paramString4);
        }
      }
    }
  }
  
  protected bb g()
  {
    return new a_();
  }
  
  public cb c(String paramString)
  {
    Text localText = this.c.createTextNode(String.valueOf(paramString));
    Object localObject = this.d.getLast();
    if ((a.b) || ((localObject instanceof Node))) {
      ((Node)localObject).appendChild(localText);
    }
    return this;
  }
  
  public cb b(String paramString)
  {
    CDATASection localCDATASection = this.c.createCDATASection(paramString);
    Object localObject = this.d.getLast();
    if ((a.b) || ((localObject instanceof Node))) {
      ((Node)localObject).appendChild(localCDATASection);
    }
    return this;
  }
  
  public cb a(DocumentFragment paramDocumentFragment)
  {
    boolean bool2 = a.b;
    boolean bool1 = a.a;
    Object localObject = this.d.getLast();
    if ((bool2) || ((localObject instanceof Node)))
    {
      Node localNode = (Node)localObject;
      NodeList localNodeList = paramDocumentFragment.getChildNodes();
      int k = localNodeList.getLength();
      int m = 0;
      do
      {
        if (m >= k) {
          break;
        }
        if (bool1) {
          break label89;
        }
        a(localNodeList.item(m));
        m++;
      } while (!bool1);
    }
    label89:
    return this;
  }
  
  protected void a(Node paramNode)
  {
    boolean bool2 = a.b;
    boolean bool1 = a.a;
    String str1 = paramNode.getNamespaceURI();
    String str2 = paramNode.getLocalName();
    String str3 = paramNode.getPrefix();
    String str4 = paramNode.getNodeValue();
    if (!bool2) {}
    switch (paramNode.getNodeType())
    {
    case 2: 
      a(str3, str2, str1, str4);
      if (!bool2) {
        if (!bool1) {
          return;
        }
      }
    case 4: 
      b(str4);
      if (!bool2) {
        if (!bool1) {
          return;
        }
      }
    case 8: 
      a(str4);
      if (!bool2) {
        if (!bool1) {
          return;
        }
      }
    case 1: 
      a(str3, str2, str1);
      NamedNodeMap localNamedNodeMap = paramNode.getAttributes();
      int k = localNamedNodeMap.getLength();
      int m = 0;
      do
      {
        if (m >= k) {
          break;
        }
        a(localNamedNodeMap.item(m));
        m++;
        if ((!bool2) && (bool1)) {
          return;
        }
      } while (!bool1);
      NodeList localNodeList = paramNode.getChildNodes();
      k = localNodeList.getLength();
      if (!bool2)
      {
        int n = 0;
        do
        {
          if (n >= k) {
            break;
          }
          a(localNodeList.item(n));
          n++;
          if (bool2) {
            break label293;
          }
          if (bool1) {
            break label291;
          }
        } while (!bool1);
        if (!bool2)
        {
          b();
          if (bool2) {
            break label316;
          }
          if (!bool1) {
            return;
          }
        }
      }
      break;
    case 7: 
      if (!bool2)
      {
        b(str2, str4);
        if (!bool1) {
          return;
        }
      }
    case 3: 
      label291:
      label293:
      label316:
      c(str4);
    }
  }
  
  private class a_
    implements bb
  {
    private NamespaceSupport a = new NamespaceSupport();
    
    public a_() {}
    
    public String a(String paramString)
    {
      boolean bool = a.b;
      String str = this.a.getURI("");
      if (!bool) {}
      str = str == null ? "" : str;
      if (!bool) {
        if (str.equals(paramString)) {
          return "";
        }
      }
      return this.a.getPrefix(paramString);
    }
    
    public String b(String paramString)
    {
      return this.a.getURI(paramString);
    }
    
    public void a(String paramString1, String paramString2)
    {
      boolean bool2 = a.b;
      boolean bool1 = a.a;
      Element localElement = (Element)i.this.d.getLast();
      if (!a(localElement, paramString1, paramString2)) {
        throw new IllegalStateException("Trying to redefine namespace prefix " + paramString2 + " that is already in use by a different mapping");
      }
      NamedNodeMap localNamedNodeMap = localElement.getAttributes();
      int i = 0;
      do
      {
        if (i >= localNamedNodeMap.getLength()) {
          break;
        }
        Node localNode = localNamedNodeMap.item(i);
        if (bool1) {
          break label209;
        }
        if (!bool2)
        {
          if ((!"xmlns".equals(localNode.getNodeName())) && ((bool2) || (!"http://www.w3.org/2000/xmlns/".equals(localNode.getNamespaceURI()))))
          {
            if (bool2) {
              continue;
            }
            if (!a(localNode, paramString1, paramString2)) {
              throw new IllegalStateException("Trying to redefine namespace prefix " + paramString2 + " that is already in use by a different mapping");
            }
          }
          i++;
        }
      } while (!bool1);
      label209:
      String str = a(paramString1);
      if (!bool2) {
        if (str != null)
        {
          if (bool2) {
            break label309;
          }
          if (str.equals(paramString2)) {
            break label306;
          }
        }
      }
      if (!bool2)
      {
        if ("".equals(paramString2)) {
          localElement.setAttribute("xmlns", paramString1);
        }
      }
      else
      {
        if (bool2) {
          break label305;
        }
        if (!bool1) {
          break label296;
        }
      }
      localElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + paramString2, paramString1);
      label296:
      label305:
      this.a.declarePrefix(paramString2, paramString1);
      label306:
      label309:
      if ((bool2) || (q.n))
      {
        if (!bool2) {}
        a.a = !bool1;
      }
      if (bool2) {
        q.o = !q.o;
      }
    }
    
    private boolean a(Node paramNode, String paramString1, String paramString2)
    {
      boolean bool = a.b;
      String str1 = paramNode.getPrefix();
      String str2 = paramNode.getNamespaceURI();
      if (!bool) {
        if (str1 == null)
        {
          if (null == paramString2) {
            break label69;
          }
          if (bool) {
            break label68;
          }
          if (!"".equals(paramString2)) {
            break label67;
          }
          break label69;
        }
      }
      if (!bool) {
        if (!str1.equals(paramString2)) {
          label67:
          label68:
          return true;
        }
      }
      label69:
      if (!bool) {}
      return str2 == null ? false : str2 == paramString1 ? true : str2.equals(paramString1);
    }
    
    public void b(String paramString1, String paramString2)
    {
      boolean bool = a.b;
      Element localElement = (Element)i.this.d.getLast();
      String str = a(paramString1);
      if ((bool) || ((str == null) || ((bool) || (!str.equals(paramString2)))))
      {
        if (!bool)
        {
          if ("".equals(paramString2)) {
            localElement.setAttribute("xmlns", paramString1);
          }
        }
        else
        {
          if (bool) {
            break label121;
          }
          if (!a.a) {
            break label112;
          }
        }
        localElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + paramString2, paramString1);
        label112:
        label121:
        this.a.declarePrefix(paramString2, paramString1);
      }
    }
    
    public void a()
    {
      this.a.pushContext();
    }
    
    public void b()
    {
      this.a.popContext();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.e.b.c.i

 * JD-Core Version:    0.7.0.1

 */